package io.netty.example.demo;

import io.netty.buffer.ByteBuf;
import io.netty.buffer.CompositeByteBuf;
import io.netty.buffer.PooledByteBufAllocator;
import io.netty.buffer.Unpooled;
import org.junit.Test;

public class FeatureTest {
    public static void main(String[] args) {
        compositeTest();
    }

    public static void compositeTest(){
        // 复合缓冲区，只是提供一个视图
        CompositeByteBuf messageBuf = Unpooled.compositeBuffer();
        ByteBuf headerBuf = Unpooled.buffer(); //创建一个堆内内存
        ByteBuf bodyBuf = Unpooled.directBuffer(); //创建一个堆外内存
        messageBuf.addComponents(headerBuf, bodyBuf);//将连个buffer组成视图
        messageBuf.removeComponent(0); // 操作buffer
        for (ByteBuf buf : messageBuf) {
            System.out.println(buf.toString());
        }
    }
}
